<template>
  <el-table-column
    v-for="extcol in extCols"
    :key="extcol.extcolName"
    :label="extcol.extcolLabel"
    align="center"
    :prop="extcol.extcolName"
    min-width="120px"
  />
</template>

<script>
export default {
  name: 'ExtColTableColumn',
  props: {
    // 被扩展表名
    tableName: {
      type: String,
      require: true
    }
  },
  data() {
    return {
      // 扩展字段
      extCols: []
    }
  },
  watch: {
    tableName(newVal, oldVal) {
      console.log('newVal', newVal)
      this.doGetTableExtCol()
    }
  },
  created() {
    this.doGetTableExtCol()
  },
  methods: {
    doGetTableExtCol: function () {
      if (this.tableName) {
        this.getTableExtCol(this.tableName).then((response) => {
          this.extCols = response.data
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
